<?php
        	
namespace Addons\Qrcode\Model;
use Home\Model\WeixinModel;
        	
/**
 * Qrcode的微信模型
 */
class WeixinAddonModel extends WeixinModel{
	function reply($dataArr, $keywordArr = array()) {
         $this->replyText ( 'QQQQQQQQQQQQQQQQQQQQ' );
	} 

	// 关注公众号事件
	public function subscribe() {
		return true;
	}
	
	// 取消关注公众号事件
	public function unsubscribe() {
		return true;
	}
	
	// 扫描带参数二维码事件
	public function scan() {


	    $data = $this->getData ();
        $token=get_token();
        $openid = get_openid();
        if($data['EventKey']!="")
        {
            $uid = $data['EventKey'];
            $openid=$data['FromUserName'];
            $Qm=M('qr_code');
            $Qwhere['token']=$token;
            $Qwhere['scene_id']=$uid;
            $Qcrede=$Qm->where($Qwhere)->find();
            $Qcrede['request_count']=$Qcrede['request_count']+1;
        }

		$this->replyText ( "你扫描的是场景为：{$Qcrede['extra_text']} 的二维码");
        return true;
	}
	
	// 上报地理位置事件
    public function location($dataArr) {

		$latitude = $dataArr ['Location_X'];
		$longitude = $dataArr ['Location_Y'];

		$this->replyText ("认真看X:".$latitude."Y:".$longitude);
        return true;
    }
	
	// 自定义菜单事件
	public function click() {
		return true;
	}

    //扫码自定义二维码事件
    public function qrcode($dataArr){
        $data=$dataArr['ScanCodeInfo'];
        $this->replyText ("二维码内容：".$data['ScanResult']);
        return true;
    }
}
        	